package com.tnxst.phexamination.public_health_docking_interface;

import com.tnxst.phexamination.constant.Trade;
import com.tnxst.phexamination.dto.ServiceDetailsDTO;
import com.tnxst.phexamination.utils.GsonUtils;
import com.tnxst.phexamination.utils.ReflectUtils;
import com.tnxst.phexamination.utils.StringUtils;
import com.tnxst.phexamination.utils.WebServiceUtils;
import com.tnxst.phexamination.vo.ContractVo;
import com.tnxst.phexamination.vo.GetSignVo;
import com.tnxst.phexamination.vo.ServiceExecDetailsVo;
import com.tnxst.phexamination.vo.ServiceExecVo;
import com.tnxst.phexamination.vo.ServicesVo;
import com.tnxst.phexamination.vo.SignVo;
import com.tnxst.phexamination.vo.TeamMemberVo;

import java.util.List;
import java.util.Map;

public class FamilySignInterface {

    /**
     * 69-2 根据医生查询签约
     * @param doctorId
     * @param doctorName
     * @param doctorTelNum
     * @param response
     */
    public static void queryContractByDoctor(String doctorId, String doctorName,String doctorTelNum,WebServiceUtils.Response response) {
        String trade = Trade.CONTRACT_MANAGE.QUERY_CONTRACT_BY_DOCTOR;
        Map<String, Object> data = StringUtils.getDataMap();
        if (StringUtils.isNotNull(doctorId))
            data.put("DoctorID",doctorId);
        if (StringUtils.isNotNull(doctorName))
            data.put("doctorName",doctorName);
        if (StringUtils.isNotNull(doctorTelNum))
            data.put("doctorTelNum",doctorTelNum);
        WebServiceUtils.call(trade,data,response);
    }

    /**
     * 69-8 新增签约
     * @param signVo
     * @param response
     */
    public static void familyDoctorSign(SignVo signVo, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.FAMILY_DOCTOR_SIGN;
        Map<String, Object> data = ReflectUtils.objectToMap(signVo);
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.putAll(data);
        WebServiceUtils.call(trade,dataMap,response);


    }


    /**
     * 69-10 获取机构服务包
     * @param name 服务包名称
     * @param useScope 10-本机构及以下，11-本机构，可以不上传（默认查询10-本机构及以下）
     * @param response
     */
    public static void getOrgServicePack(String name, Integer useScope, WebServiceUtils.Response<List> response){
        String trade = Trade.CONTRACT_MANAGE.GET_ORG_SERVICE_PACK;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        if (StringUtils.isNotNull(name))
            dataMap.put("Name",name);
        if (StringUtils.isNotNull(useScope))
            dataMap.put("UseScope",useScope);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-3 获取团队信息
     * @param type
     * @param teamName
     * @param pageSize
     * @param pageIndex
     * @param response
     */
    public static void getTeamInfo(Integer type, String teamName, Integer pageSize,
                                   Integer pageIndex, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_TEAM_INFO;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        if (StringUtils.isNotNull(type))
            dataMap.put("Type",type);
        if (StringUtils.isNotNull(teamName))
            dataMap.put("TeamName",teamName);
        dataMap.put("PageSize",pageSize);
        dataMap.put("PageIndex",pageIndex);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-4 获取团队成员信息
     * @param teamId
     * @param empId
     * @param response
     */
    public static void getTeamMemberInfo(String teamId, String empId, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_TEAM_MEMBER_INFO;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        if (StringUtils.isNotNull(teamId))
            dataMap.put("teamId",teamId);
        if (StringUtils.isNotNull(empId))
            dataMap.put("empId",empId);
        WebServiceUtils.call(trade,dataMap,response);

    }


    /**
     * 69-5 新建/更新团队信息
     * @param teamId 团队ID
     * @param teamName 团队名称
     * @param teamType 团队类型 （专科 全科）
     * @param remark 团队描述
     * @param response
     */
    public static void saveOrUpdateTeamInfo(String teamId, String teamName, String teamType,
                                            String remark, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.SAVE_OR_UPDATE_TEAM_INFO;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        if (StringUtils.isNotNull(teamId))
            dataMap.put("TeamID",teamId);
        if (StringUtils.isNotNull(teamName))
            dataMap.put("TeamName",teamName);
        if (StringUtils.isNotNull(teamType))
            dataMap.put("TeamType",teamType);
        if (StringUtils.isNotNull(remark))
            dataMap.put("Remark",remark);
        WebServiceUtils.call(trade,dataMap,response);


    }

    /**
     * 69-6 新建/更新成员信息
     * @param teamMemberVo
     * @param response
     */
    public static void  saveOrUpdateMemberInf(TeamMemberVo teamMemberVo, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.SAVE_OR_UPDATE_MEMBER_INFO;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        Map<String, Object> data = ReflectUtils.objectToMap(teamMemberVo);
        dataMap.putAll(data);
        WebServiceUtils.call(trade,dataMap,response);
    }

    /**
     * 69-7 获取本机构医护人员信息
     * @param queryType
     * @param medWorkerName
     * @param telPhone
     * @param pageSize
     * @param pageIndex
     * @param response
     */
    public static void queryMemberInfoByOrg(String queryType, String medWorkerName, String telPhone,
                                            Integer pageSize, Integer pageIndex, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.QUERY_MEMBER_INFO_BY_ORG;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        if (StringUtils.isNotNull(medWorkerName))
            dataMap.put("MedWorkerName",medWorkerName);
        if (StringUtils.isNotNull(queryType))
            dataMap.put("QueryType",queryType);
        if (StringUtils.isNotNull(telPhone))
            dataMap.put("Telphone",telPhone);
        dataMap.put("PageSize",pageSize);
        dataMap.put("PageIndex",pageIndex);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-9 获取居民信息
     * @param personName
     * @param pageSize
     * @param pageIndex
     * @param response
     */
    public static void getResidentInfo(String personName,Integer pageSize,
                                       Integer pageIndex, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_RESIDENT_INFO;
        Map<String, Object> dataMap = StringUtils.getPageDataMap(pageSize, pageIndex);
        if (StringUtils.isNotNull(personName))
            dataMap.put("PersonName",personName);
        WebServiceUtils.call(trade,dataMap,response);
    }

    /**
     * 69-11 获取签约
     * @param pageSize
     * @param pageIndex
     * @param getSignVo
     * @param response
     */
    public static void getSign(Integer pageSize, Integer pageIndex,
                               GetSignVo getSignVo, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_SIGN;
        Map<String, Object> dataMap = StringUtils.getPageDataMap(pageSize, pageIndex);
        Map<String, Object> map = ReflectUtils.objectToMap(getSignVo);
        dataMap.putAll(map);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-13 解约
     * @param id
     * @param cancelReason 解约原因
     * @param response
     */
    public static void termination(String id, String cancelReason, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.TERMINATION;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("ID",id);
        dataMap.put("CancelReason",cancelReason);
        if (StringUtils.isNull(cancelReason))
            dataMap.put("CancelReason","");
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-15 获取签约单详情
     * @param contractId 签约单ID
     * @param response
     */
    public static void getSignFormDetail(String contractId, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_SIGN_FORM_DETAIL;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("ContracID",contractId);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-19 删除团队成员
     * @param memberId
     * @param response
     */
    public static void deleteTeamMember(String memberId, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.DELETE_TEAM_MEMBER;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("MemberId",memberId);
        WebServiceUtils.call(trade,dataMap,response);


    }

    /**
     * 69-21 根据服务包获取包内容
     * @param servicePackId
     * @param pageSize
     * @param pageIndex
     * @param response
     */
    public static void getPackContentByPackId(String servicePackId,Integer pageSize,
                                              Integer pageIndex, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_PACK_CONTENT_BY_PACK_ID;
        Map<String, Object> dataMap = StringUtils.getPageDataMap(pageSize, pageIndex);
        dataMap.put("ServicePackId",servicePackId);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-22 创建和更新机构级服务包 (未匹配)
     * @param servicesVo
     * @param response
     */
    public static void saveOrUpdateOrgPack(ServicesVo servicesVo, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.SAVE_OR_UPDATE_ORG_PACK;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        Map<String, Object> services = ReflectUtils.objectToMap(servicesVo);
        if (services == null)
            return;
        dataMap.put("Services",services);
        WebServiceUtils.call(trade,dataMap,response);
    }

    /**
     * 69-23 创建和修改服务包内容  (未匹配)
     * @param serviceDetailVo
     * @param response
     */
    public static void saveOrUpdatePackContent(ServiceDetailsDTO serviceDetailVo, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.SAVE_OR_UPDATE_PACK_CONTENT;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        Map<String, Object> services = ReflectUtils.objectToMap(serviceDetailVo);
        if (services == null)
            return;
        dataMap.put("ServiceDetail",services);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-25 根据签约合同获取服务包
     * @param contractId
     * @param response
     */
    public static void getServicePackBySign(String contractId, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.GET_SERVICE_PACK_BY_SIGN;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("ContractId",contractId);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-26 重点人群标签验证
     * @param personId
     * @param tags
     * @param response
     */
    public static void keyGroupVerification(String personId, String tags,
                                            WebServiceUtils.Response response) {

        String trade = Trade.CONTRACT_MANAGE.KEY_GROUP_VERIFICATION;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("PersonId",personId);
        dataMap.put("Tags",tags);
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-28 家庭医生签约续约
     * @param contractVo
     * @param response
     */
    public static void contract(ContractVo contractVo, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.CONTRACT;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        Map<String, Object> data = ReflectUtils.objectToMap(contractVo);
        dataMap.putAll(data);
        WebServiceUtils.call(trade,dataMap,response);
    }

    /**
     * 69-29 新增/更新服务执行
     * @param serviceExec
     * @param serviceExecDetailsVos
     * @param response
     */
    public static void saveOrUpdateServicePerform(ServiceExecVo serviceExec, List<ServiceExecDetailsVo> serviceExecDetailsVos,
                                                  WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.SAVE_OR_UPDATE_SERVICE_PERFORM;
        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("ServiceExec", GsonUtils.toJson(serviceExec));
        dataMap.put("ServiceExecDetails",GsonUtils.toJson(serviceExecDetailsVos));
        WebServiceUtils.call(trade,dataMap,response);

    }

    /**
     * 69-30 删除服务执行
     * @param execId
     * @param response
     */
    public static void deleteServicePerform(String execId, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.DELETE_SERVICE_PERFORM;

        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("ExecID",execId);

        WebServiceUtils.call(trade,dataMap,response);
    }

    /**
     * 69-31 查询服务执行数据
     * @param execId
     * @param response
     */
    public static void queryServicePerformData(String execId, WebServiceUtils.Response response){
        String trade = Trade.CONTRACT_MANAGE.QUERY_SERVICE_PERFORM_DATA;

        Map<String, Object> dataMap = StringUtils.getDataMap();
        dataMap.put("ExecID",execId);

        WebServiceUtils.call(trade,dataMap,response);

    }














}
